package com.batch.decider;

import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
import org.springframework.batch.core.job.flow.JobExecutionDecider;

import java.util.Random;

// 自定义决策器
public class StatusDecider1 implements JobExecutionDecider {


    /**
     * @Description: decide 决策器，先执行odd奇数
     * @Param: [jobExecution, stepExecution]
     * @Return: org.springframework.batch.core.job.flow.FlowExecutionStatus
     */
    @Override
    public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
        int count = new Random().nextInt(3);
        if(count==0){
            return new FlowExecutionStatus("A");
        }else if(count==1){
            return new FlowExecutionStatus("B");
        }else {
            return new FlowExecutionStatus("C");
        }
    }
}
